<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="lib/vue-2.4.0.js"></script>
    <script src="lib/vue-router-3.0.1.js"></script>
</head>
<body>
<div id="app">
    {{msgForSon}}
    <com1 :parentmsg="msg" @func="getMsgForSon"></com1>
</div>
<template id="tmpl">
    <div>
        <h1>子元素----{{parentmsg}}</h1>
        <input type="button" value="向父组件传递消息" @click="sendMsg">
    </div>
</template>
<script>
    var com1={
        template:'#tmpl',
        props:['parentmsg'],
        data(){
            return{
                msg:'做一个孝顺的孩子，给爸爸一些钱去挥霍吧！'
            }
        },
        methods:{
            sendMsg(){
                this.$emit('func',this.msg)
            }
        }
    }
    var vm=new Vue({
        el:"#app",
        data:{
            msg:'父组件中的数据，爸爸有100元钱，想要吗',
            msgForSon:''
        },
        methods:{
            getMsgForSon(data){
                this.msgForSon=data
                console.log(data)
            }
        },
        components:{
            com1
        }
    })
</script>
</body>
</html>